from concurrent.futures import ProcessPoolExecutor
import time
import os


def task(n):
    print(os.getpid())
    time.sleep(2)
    return n, os.getpid()


def call_back(n):
    print('call_back:', n.result())


if __name__ == '__main__':
    pool = ProcessPoolExecutor(5)

    t_list=list()
    for i in range(20):
        res = pool.submit(task, i).add_done_callback(call_back)
        # t_list.append(res)

    # for t in t_list:
    #     print(t.result())